#include "PDTIfElse.h"
#include "PDTCodeGraph.h"

void PDTIfElse::setCondition(PDTExpBool & condition){
	writers[0]=&condition;
	condition.addReader(this);

	addChild(&condition);
	condition.addParent(this);
}
void PDTIfElse::setIfResult(PDTStatement &ifResult){
	writers[1]=&ifResult;
	ifResult.addReader(this);

	addChild(&ifResult);
	ifResult.addParent(this);
}
void PDTIfElse::setElseResult(PDTStatement &elseResult){
	writers[2]=&elseResult;
	elseResult.addReader(this);

	addChild(&elseResult);
	elseResult.addParent(this);
}


PDTExpBool * PDTIfElse::getCondition(){
	return dynamic_cast<PDTExpBool *>(writers[0]);
}

PDTStatement * PDTIfElse::getIfResult(){
	return dynamic_cast<PDTStatement *>(writers[1]);
}

PDTStatement * PDTIfElse::getElseResult(){
	return dynamic_cast<PDTStatement *>(writers[2]);

}

PDTIfElse::PDTIfElse(PDTCodeGraph & CG,PDTExpBool & condition,PDTStatement & ifResult,PDTStatement & elseResult):PDTStatement(CG){
	addWriter(&condition);
	condition.addReader(this);
	addChild(&condition);
	condition.addParent(this);

	addWriter(&ifResult);
	ifResult.addReader(this);
	addChild(&ifResult);
	ifResult.addParent(this);

	addWriter(&elseResult);
	elseResult.addReader(this);
	addChild(&elseResult);
	elseResult.addParent(this);
}
